cmake_minimum_required(VERSION 4.1)

aux_source_directory(Code/Core/Container core)
aux_source_directory(Code/Core/Env core)
aux_source_directory(Code/Core/FileIO core)
aux_source_directory(Code/Core/Math core)
aux_source_directory(Code/Core/Mem core)
aux_source_directory(Code/Core/Network core)
aux_source_directory(Code/Core/Process core)
aux_source_directory(Code/Core/Profile core)
aux_source_directory(Code/Core/Reflection core)
aux_source_directory(Code/Core/Reflection/MetaData core)
aux_source_directory(Code/Core/Strings core)
aux_source_directory(Code/Core/Time core)
aux_source_directory(Code/Core/Tracing core)

aux_source_directory(External/xxHash/0.8.2 xxhash)
aux_source_directory(External/Zstd/zstd-1.5.7/lib zstd)
aux_source_directory(External/Zstd/zstd-1.5.7/lib/common zstd)
aux_source_directory(External/Zstd/zstd-1.5.7/lib/compress zstd)
aux_source_directory(External/Zstd/zstd-1.5.7/lib/decompress zstd)
aux_source_directory(External/LZ4/lz4-1.10.0/lib lz4)

aux_source_directory(Code/Tools/Fbuild/FBuildCore fbuildcore)
aux_source_directory(Code/Tools/Fbuild/FBuildCore/BFF fbuildcore)
aux_source_directory(Code/Tools/Fbuild/FBuildCore/BFF/Functions fbuildcore)
aux_source_directory(Code/Tools/Fbuild/FBuildCore/BFF/Tokenizer fbuildcore)
aux_source_directory(Code/Tools/Fbuild/FBuildCore/Cache fbuildcore)
aux_source_directory(Code/Tools/Fbuild/FBuildCore/ExeDrivers/Compiler fbuildcore)
aux_source_directory(Code/Tools/Fbuild/FBuildCore/Graph fbuildcore)
aux_source_directory(Code/Tools/Fbuild/FBuildCore/Graph/MetaData fbuildcore)
aux_source_directory(Code/Tools/Fbuild/FBuildCore/Helpers fbuildcore)
aux_source_directory(Code/Tools/Fbuild/FBuildCore/Helpers/Report fbuildcore)
aux_source_directory(Code/Tools/Fbuild/FBuildCore/Protocol fbuildcore)
aux_source_directory(Code/Tools/Fbuild/FBuildCore/WorkerPool fbuildcore)
aux_source_directory(Code/Tools/Fbuild/FBuildWorker fbuildworker)

aux_source_directory(Code/Tools/Fbuild/FBuild fbuild)
aux_source_directory(Code/Tools/Fbuild/FBuildWorker/Worker fbuildworker)

aux_source_directory(Code/OSUI osui)
list(FILTER osui EXCLUDE REGEX ".*\\.mm$")

add_compile_options(/std:c++17)
include_directories(
    Code 
    External/xxHash/0.8.2
    External/Zstd/zstd-1.5.7/lib
    External/VSProjTypeExtractor 
    External/LZ4/lz4-1.10.0/lib
)
link_directories(${CMAKE_BINARY_DIR}/Code/Debug)
add_definitions(-D__WINDOWS__ -DDEBUG)

add_library(xxhash ${xxhash})
target_compile_definitions(xxhash PUBLIC -DXXH_NAMESPACE=xxHashLib_)

add_library(Core ${core})
add_library(zstd ${zstd})
add_library(Lz4 ${lz4})
add_library(FBuildCore ${fbuildcore})
add_library(OSUI ${osui})

add_executable(FBuild ${fbuild})
add_executable(FBuildWorker WIN32 ${fbuildworker} Code/Tools/Fbuild/FBuildWorker/MainWindowResource.rc)
target_link_libraries(FBuild FBuildCore Core Lz4 zstd xxhash ws2_32 iphlpapi)
target_link_libraries(FBuildWorker FBuildCore Core OSUI ws2_32 Lz4 zstd xxhash iphlpapi comctl32)